<?php
if(isset($_REQUEST['fuseaction_back'])) {
	$fuseaction_back=$_REQUEST['fuseaction_back'];
}else{
	$fuseaction_back = "";
}  

// id cua ho so
$v_record_id = "";
if(isset($_REQUEST['hdn_record_id'])){
	$v_record_id = $_REQUEST['hdn_record_id'];
}
// current_status va detail_status
$v_current_status = "";
$v_detail_status = "";
$v_pk_record_work = "";
$v_worktype = "";
if(isset($_REQUEST['hdn_current_status'])){
	$v_current_status = $_REQUEST['hdn_current_status'];
}
if(isset($_REQUEST['hdn_detail_status'])){
	$v_detail_status = $_REQUEST['hdn_detail_status'];
}
if(isset($_REQUEST['hdn_pk_record_work'])){
	$v_pk_record_work = $_REQUEST['hdn_pk_record_work'];
}
/*if(isset($_REQUEST['hdn_pk_record_work'])){
	$v_worktype = $_REQUEST['hdn_pk_record_work'];
}*/

// ngay thuc hien
$v_work_date = date("d/m/Y");
// nguoi thuc hien
$v_worker_id = $_SESSION['staff_id'];
// ghi log current_status va detail_status lai, insert vao bang T_ONEGATE_RECORD_WORK_LOG_STATUS
if(_is_sqlserver())
{
	$sql = "Exec Onegate_RecordWorkUndo " ;
	$sql = $sql . "'" . $v_record_id . "'";
	$sql = $sql . "," . $v_worker_id;
	//$sql = $sql . ",'" . $v_worktype . "'";
	$sql = $sql . ",'" . _ddmmyyyy_to_yyyymmdd($v_work_date) . "'" ;
	
	//echo $sql .'<br>' ; exit(1);
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$rs = $ado_conn->GetRow($sql); 
	$v_error = _replace_bad_char(trim($rs['RET_ERROR']));
}
sleep(0);
if (!is_null($v_error) && $v_error<>""){?>
	<script>
		alert("<?php echo $v_error; ?>");
		if (_MODAL_DIALOG_MODE==1){
			window.location = "<?php echo $v_goto_url; ?>";
		}else{
			window.history.back();
		}	
	</script><?php
	exit;
}
?>
<form action="index.php" method="post" name="f_back"> 
  <input type="hidden" name="fuseaction" value="<?php echo $fuseaction_back; ?>">
  <input type="hidden" name="fuseaction_back" value="<?php echo $fuseaction_back; ?>">
  <input type="hidden" name="hdn_recordtype_filter" value="<?php echo $v_recordtype_filter; ?>">
</form> 
<Script language="javascript">
	document.forms(0).submit();
</Script> 
